from faster_whisper import WhisperModel


def main():
    # 模型： small medium large-v3 large-v3-turbo
    model = WhisperModel(model_size_or_path="large-v3-turbo", device="cuda", compute_type="float16")
    segments, info = model.transcribe("E:\\Files\\music\\juhao.mp3",
                                      # initial_prompt="以下是普通话的句子。"
                                      )

    # 输出语言信息
    print(f"检测语言: {info.language} (概率: {info.language_probability:.2%})")

    print(f"总时长: {info.duration:.2f} 秒")

    # 遍历分段文本
    for segment in segments:
        print(f"[{segment.start:.1f}s → {segment.end:.1f}s] {segment.text}")


if __name__ == '__main__':
    main()
